version 14.0

log using "\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure2.log", replace

set more off
#delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      africancabinets_figure2.do                      *;
*       Date:           September 17, 2016                              *;
*       Author:         Molly Ariotti and Sona Golder                   *;
*       Purpose:      	Produce Figure 2 for CPS African portfolio      *;
*                       allocation paper.                               *;
* 	    Input File:     Africa.dta                                      *;
*       Output File:    figure2.log, africa.eps                         *;
*       Data Output:    none                                            *;             
*       Previous file:  none                                            *;
*       Machine:        laptop                           				*;
*     ****************************************************************  *;
*     ****************************************************************  *;

use "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa.dta";

sum;

*     ****************************************************************  *;
*       Create perfect proportionality data                             *;
*     ****************************************************************  *;

set obs 100;
gen seats=.;
replace seats=_n/100 if _n<101;
gen ports=.;
replace ports=_n/100 if _n<101;

*     ****************************************************************  *;
*       Produce Figure 2                                                *;
*     ****************************************************************  *;

scatter portfolioshare seatshare if formateur==1, msymbol(O) mcolor(red) msize(medsmall)
        || scatter portfolioshare seatshare if formateur==0, msymbol(Oh) mcolor(eltblue)  msize(medsmall) 
        || line ports seats if seatshare>0, lcolor(black) clpattern(solid) 
        legend(col(1) size(2.5) region(lstyle(color(white))) order(1 2) position(5) ring(0) label(1 "{stSerif:Formateur Party}") label(2 "{stSerif:Not a Formateur Party}"))
        xtitle("{stSerif:Share of Government's Legislative Seats}", size(3) height(7)) 
        ytitle("{stSerif:Share of Cabinet Portfolios}" , size(3) height(7))
        xlabel(0 0.2 0.4 0.6 0.8 1.0, nogrid labsize(2.5))
        ylabel(0 0.2 0.4 0.6 0.8 1.0, nogrid labsize(2.5)) 
        scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));
        
graph export "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\africa.eps", replace;



*     ****************************************************************  *;
*       What is the average distance from the 45 degree line?           *;
*     ****************************************************************  *;

gen error = abs(portfolioshare-seatshare);

egen sum_error = sum(error);

gen average_error=sum_error/76;

sum average_error;

gen error2 = abs(portfolioshare-seatshare) if formateur==1;

egen sum_error2 = sum(error2);

gen average_error2=sum_error2/26;

sum average_error2;

log close;
exit;
